home *** CD-ROM | disk | FTP | other *** search
- /*
- ** pixeltest.c
- **
- ** determines the speed of context switches between PowerPC and M68k
- **
- ** Written by Frank Wille, March 98
- **
- */
-
- #include <stdio.h>
-
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <exec/memory.h>
- #include <dos/dos.h>
- #include <graphics/gfx.h>
- #include <graphics/gfxbase.h>
- #include <intuition/intuition.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/graphics.h>
- #include <proto/intuition.h>
-
-
- #define WIDTH 128
- #define HEIGHT 80
-
-
- struct GfxBase *GfxBase = NULL;
- struct IntuitionBase *IntuitionBase = NULL;
-
-
-
- main()
- {
- static struct TagItem wintags[] = {
- WA_Left,160,
- WA_Top,100,
- WA_Width,WIDTH,
- WA_Height,HEIGHT,
- WA_Borderless,TRUE,
- WA_Activate,TRUE,
- WA_RMBTrap,TRUE,
- TAG_DONE,0
- };
- struct DateStamp ds1,ds2;
- struct Window *win = NULL;
- struct RastPort *rp;
- int x,y;
- double d;
-
- if (!(IntuitionBase = (struct IntuitionBase *)
- OpenLibrary("intuition.library",36))) {
- printf("no intuition.library!\n");
- exit(20);
- }
- if (!(GfxBase = (struct GfxBase *)
- OpenLibrary("graphics.library",36))) {
- CloseLibrary((struct Library *)IntuitionBase);
- printf("no graphics.library!\n");
- exit(20);
- }
-
- if (win = OpenWindowTagList(NULL,wintags)) {
- rp = win->RPort;
- DateStamp(&ds1);
- for (y=0; y<HEIGHT; y++) {
- for (x=0; x<WIDTH; x++) {
- SetAPen(rp,x&3);
- WritePixel(rp,x,y);
- }
- }
- DateStamp(&ds2);
- CloseWindow(win);
-
- d = ((double)(ds2.ds_Days-ds1.ds_Days)*24*60*60*TICKS_PER_SECOND +
- (double)(ds2.ds_Minute-ds1.ds_Minute)*60*TICKS_PER_SECOND +
- (double)(ds2.ds_Tick-ds1.ds_Tick)) / (double)TICKS_PER_SECOND;
- printf("Wrote %d pixels in %f seconds.\n"
- "Test program did %f context switches per second.\n",
- WIDTH*HEIGHT,d,(WIDTH*HEIGHT*2.0)/d);
- }
- else
- printf("Can't open test window!\n");
-
- CloseLibrary((struct Library *)GfxBase);
- CloseLibrary((struct Library *)IntuitionBase);
- }
-